﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using NetworkEasyShare;
using System.Collections.ObjectModel;

namespace NetworkEasyShare
{
    /// <summary>
    /// Interaction logic for search.xaml
    /// </summary>
    public partial class search : Window
    {
        public Transfer transfer;
        private ObservableCollection<ComputerData> mComputerCollection;

        public search(Transfer file) {
            transfer = file;
            transfer.setHostAddr("127.0.0.1");
            transfer.setHostPort(14111);

            mComputerCollection = new ObservableCollection<ComputerData>();

            broadcastMessage bMessage = new broadcastMessage(false, this.ComputerCollection);
            InitializeComponent();
        }

        private void closeButton_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();
        }

        #region Progress Dialog

        private void ShowProgressDialog()
        {
            progressDialog ProgressDialog = new progressDialog();
            ProgressDialog.ShowDialog();
            ProgressDialog = null;
        }

        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            Thread progressThread = new Thread(new ThreadStart(ShowProgressDialog));
            progressThread.SetApartmentState(ApartmentState.STA);
            progressThread.Start();
            this.Hide();
        }
        #endregion
 
    public class ComputerData
    {
        public string Nickname { get; set; }
        public string IPAddr { get; set; }
        public string MACAddr { get; set; }
    }

    public ObservableCollection<ComputerData> ComputerCollection
    { get { return mComputerCollection; } }
    }
}
